# include <bits/stdc++.h>
# define N 100005
using namespace std;
using pq=priority_queue<pair<int,int>>;
using namespace std;
int n;
vector<int> G[N];
void merge(pq &a,pq &b)
{
    if(a.size()<b.size())
        swap(a,b);
    while(!b.empty())
    {
        a.push(b.top());
        b.pop();
    }
}
pq res[N];
void dfs(int x,int fa)
{
    if(G[x].size()-(fa!=0)==0)
    {
        res[x].push({1,0});
        return ;
    }
    for(auto to:G[x])
        if(to!=fa)
        {
            dfs(to,x);
            merge(res[x],res[to]);
        }
    if(res[x].size()==1)
    {
        auto [now,d]=res[x].top();
        res[x].pop();
        if(!d)
            res[x].push({now+1,0});
        else
            res[x].push({now+2,d-1});
        return ;
    }
    else
    {
        auto [now1,d1]=res[x].top();
        res[x].pop();
        auto [now2,d2]=res[x].top();
        res[x].pop();
        if(now1%2==0 && now2%2==0)
            res[x].push({now1+now2,d1+d2+1});
        else
            res[x].push({now1+now2+1,d1+d2});
    }
}
int main()
{
    freopen("bird.in","r",stdin);
    freopen("bird.out","w",stdout);
    cin>>n;
    for(int i=1;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(1,0);
    cout<<res[1].top().first<<endl;
    return 0;
}